package com.neuedu.funlifebbs.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.neuedu.funlifebbs.bean.Honors;
import com.neuedu.funlifebbs.dao.HonorsMapper;
import com.neuedu.funlifebbs.query.HonorsQuery;
import com.neuedu.funlifebbs.service.HonorsService;

/**
 * @author weiminqiao
 * @version 创建时间：2019年8月19日 下午8:38:02
 * 实现类
 */
@Service
public class HonorsServiceImpl  implements HonorsService{

	
	@Autowired

	HonorsMapper honorsMapper;

	@Override
	public Honors findById(int id) {
		
		return honorsMapper.findById(id);
	}

	/**
	 *  使用分页插件
	 */
	@Override
	public PageInfo<Honors> query(HonorsQuery honorsQuery) {
		if (honorsQuery.isPaging()) {
			
			PageHelper.startPage(honorsQuery.getPageNum(),
					honorsQuery.getLimit());
			Page<Honors> pageInfo = (Page<Honors>) honorsMapper.query(honorsQuery);
			return pageInfo.toPageInfo();
		} else {
			PageInfo<Honors> pageInfo = new PageInfo<Honors>(
					honorsMapper.query(honorsQuery));
			return pageInfo;
		}
	}


	@Override
	public int add(Honors honors) {
		return honorsMapper.add(honors);
	}

	@Override
	public int deleteById(int id) {
		return honorsMapper.deleteById(id);
	}

	@Override
	public int update(Honors honors) {
		return honorsMapper.update(honors);
	}
}
